﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RegisterationCommon.Student;
using RegisterationCommon.Common;
using RegisterationCommon.School;
using System.Data;
using RegisterationCommon.Education;

namespace RegisterationSystem.Space_Student
{
    public partial class student_management : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["hidsid"] = "1";
                if (!StudentInfo.Current.IsLogin())
                {
                    Message.Send(10001);
                }
                Bind();
            }
            CommunityBond();
            if (!SysSet.IsStopSignUp())//截止登记时间
            {
                this.timeout.Style["display"]="";
                
            }
        }
        public void CommunityBond()
        {
            string schoolID = "var tschoolID=[";
            DataTable dt3 = DBAction.GetDTFromSQL("select * from Community");
            for (int n = 0; n < dt3.Rows.Count; n++)
            {
                if (n != dt3.Rows.Count - 1)
                {
                    schoolID = schoolID + "['" + dt3.Rows[n]["ID"].ToString() + "'" + ",'" + dt3.Rows[n]["SclID"].ToString() + "'" + "],";
                }
                else
                {
                    schoolID = schoolID + "['" + dt3.Rows[n]["ID"].ToString() + "'" + ",'" + dt3.Rows[n]["SclID"].ToString() + "'" + "]";
                }
            }
            schoolID = schoolID + "];";

            string parentID = "0";
            string jsStart = "<script>";
            string jsEnd = "</script>";
            string parentJs = "var tparent=[";
            string childJs = "var tchilds=[";
            string childJs1 = "var tchilds1=[";
            DataTable dt = DBAction.GetDTFromSQL("select * from Community where pid=" + parentID);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (i != dt.Rows.Count - 1)
                {
                    parentJs = parentJs + "['" + dt.Rows[i]["ID"].ToString() + "'" + ",'" + dt.Rows[i]["Name"].ToString() + "'" + "],";
                    DataTable dt1 = DBAction.GetDTFromSQL("select * from Community where pid=" + dt.Rows[i]["ID"].ToString());
                    for (int j = 0; j < dt1.Rows.Count; j++)
                    {
                        childJs = childJs + "['" + dt1.Rows[j]["ID"].ToString() + "'" + ",'" + dt1.Rows[j]["Name"].ToString() + "'" + ",'" + dt1.Rows[j]["Pid"].ToString() + "'" + "],";
                        //第三级
                        DataTable dtt1 = DBAction.GetDTFromSQL("select * from Community where pid=" + dt1.Rows[j]["ID"].ToString());
                        for (int k = 0; k < dtt1.Rows.Count; k++)
                        {
                            childJs1 = childJs1 + "['" + dtt1.Rows[k]["ID"].ToString() + "'" + ",'" + dtt1.Rows[k]["Name"].ToString() + "'" + ",'" + dtt1.Rows[k]["Pid"].ToString() + "'" + "],";

                        }
                        //end
                    }
                }
                else
                {
                    parentJs = parentJs + "['" + dt.Rows[i]["ID"].ToString() + "'" + ",'" + dt.Rows[i]["Name"].ToString() + "'" + "]";
                    DataTable dt2 = DBAction.GetDTFromSQL("select * from Community where pid=" + dt.Rows[i]["ID"].ToString());
                    for (int k = 0; k < dt2.Rows.Count; k++)
                    {
                        if (k != dt2.Rows.Count - 1)
                        {
                            childJs = childJs + "['" + dt2.Rows[k]["ID"].ToString() + "'" + ",'" + dt2.Rows[k]["Name"].ToString() + "'" + ",'" + dt2.Rows[k]["Pid"].ToString() + "'" + "],";
                            //第三级
                            DataTable dtt1 = DBAction.GetDTFromSQL("select * from Community where pid=" + dt2.Rows[k]["ID"].ToString());

                            for (int n = 0; n < dtt1.Rows.Count; n++)
                            {
                                childJs1 = childJs1 + "['" + dtt1.Rows[n]["ID"].ToString() + "'" + ",'" + dtt1.Rows[n]["Name"].ToString() + "'" + ",'" + dtt1.Rows[n]["Pid"].ToString() + "'" + "],";

                            }
                            //end
                        }
                        else
                        {
                            childJs = childJs + "['" + dt2.Rows[k]["ID"].ToString() + "'" + ",'" + dt2.Rows[k]["Name"].ToString() + "'" + ",'" + dt2.Rows[k]["Pid"].ToString() + "'" + "]";
                            //第三级
                            DataTable dtt2 = DBAction.GetDTFromSQL("select * from Community where pid=" + dt2.Rows[k]["ID"].ToString());
                            for (int m = 0; m < dtt2.Rows.Count; m++)
                            {
                                if (m != dtt2.Rows.Count - 1)
                                {
                                    childJs1 = childJs1 + "['" + dtt2.Rows[m]["ID"].ToString() + "'" + ",'" + dtt2.Rows[m]["Name"].ToString() + "'" + ",'" + dtt2.Rows[m]["Pid"].ToString() + "'" + "],";
                                }
                                else
                                {
                                    childJs1 = childJs1 + "['" + dtt2.Rows[m]["ID"].ToString() + "'" + ",'" + dtt2.Rows[m]["Name"].ToString() + "'" + ",'" + dtt2.Rows[m]["Pid"].ToString() + "'" + "]";
                                }
                            }
                            //end
                        
                        
                        }
                    }
                }
            }
            parentJs = parentJs + "];";
            if (childJs.Substring(childJs.Length - 1, 1) == ",")
            {
                childJs = childJs.Substring(0, childJs.Length - 1);
            }
            childJs = childJs + "];";

            if (childJs1.Substring(childJs1.Length - 1, 1) == ",")
            {
                childJs1 = childJs1.Substring(0, childJs1.Length - 1);
            }
            childJs1 = childJs1 + "];";

            //string callJS = "for(var i=0;i<tparent.length;i++){";
            //callJS += "$(\"#scommunity\").append(\"<option value='\" + tparent[i][0]+ \"'>\" + tparent[i][1] + \"</option>\");";
            //callJS += "}";
            //callJS += "setChildNode("+ViewState["hidsid"].ToString()+",tchilds);plasschoolload(tschoolID);";
            //callJS += "$(\"#scommunity\").change(function(obj){ $(\"#xcommunity\").html('');setChildNode($(this).val(),tchilds);plasschooldialog(tschoolID);});";
            //callJS += "function setChildNode(parentID,childs){ for(var j=0;j<childs.length;j++){ if(childs[j][2]==parentID)	{";
            //callJS += "$(\"#xcommunity\").append(\"<option value='\" + childs[j][0]+ \"'>\" + childs[j][1] + \"</option>\");}}}";
            //callJS += "$(\"#xcommunity\").change(function(obj){plasschoolIDValue(tschoolID);});";
            //cpJS2.Text = jsStart + "$(function () {" + schoolID + parentJs + childJs + callJS + "});" + jsEnd;

            string callJS = "for(var i=0;i<tparent.length;i++){";
            callJS += "$(\"#pcommunity\").append(\"<option value='\" + tparent[i][0]+ \"'>\" + tparent[i][1] + \"</option>\");";
            callJS += "}";
            callJS += "setChildNode(" + ViewState["pianid"].ToString() + ",tchilds);plasschoolload(tschoolID);";//页面初始赋值
            callJS += "$(\"#pcommunity\").change(function(obj){ $(\"#scommunity\").html('');setChildNode2($(this).val() ,tchilds);plasschooldialog(tschoolID);});";//进城

            callJS += "function setChildNode(parentID,childs){var i='a'; for(var j=0;j<childs.length;j++){ if(childs[j][2]==parentID)	{";
            callJS += "$(\"#scommunity\").append(\"<option value='\" + childs[j][0]+ \"'>\" + childs[j][1] + \"</option>\");i=j;}}}setChild1Node(" + ViewState["hidsid"].ToString() + ",tchilds1);";

            callJS += "function setChildNode2(parentID,childs){var i='a'; for(var j=0;j<childs.length;j++){ if(childs[j][2]==parentID)	{";
            callJS += "$(\"#scommunity\").append(\"<option value='\" + childs[j][0]+ \"'>\" + childs[j][1] + \"</option>\");i=j;}}if(i!='a'){$(\"#xcommunity\").html('');setChild1Node(childs[i][0],tchilds1);}}";


            callJS += "$(\"#scommunity\").change(function(obj){$(\"#xcommunity\").html('');setChild1Node($(this).val(),tchilds1);plasschoolIDValue1(tschoolID);});";
            //社区变化


            callJS += "function setChild1Node(parent1ID,childs){ for(var j=0;j<childs.length;j++){ if(childs[j][2]==parent1ID)	{";
            callJS += "$(\"#xcommunity\").append(\"<option value='\" + childs[j][0]+ \"'>\" + childs[j][1] + \"</option>\");}}}";

            callJS += "$(\"#xcommunity\").change(function(obj){plasschoolIDValue(tschoolID);});";//小区变化
            cpJS2.Text = jsStart + "$(function () {" + schoolID + parentJs + childJs + childJs1 + callJS + "});" + jsEnd;

        
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        void Bind()
        {
            


            //绑定公告
            //Repeater2.DataSource = DBAction.GetDTFromSQL("select top 6 * from Notice where (Recrive=0 or Recrive=2) and Status=0 order by id desc");
            //Repeater2.DataBind();

            //////lblname.Text = Cookies.Get("TrueName").ToString();
            //////SchoolInfo s = new SchoolInfo();
            //////s.GetSchoolInfoByID(StudentInfo.Current.SchID);
            ////////是否足龄
            //////if (StudentInfo.Current.IsMatured)
            //////{
            //////    //是否是室内区外学生
            //////    if (StudentInfo.Current.SchID == 0 && StudentInfo.Current.HouseAreaID == 1)
            //////    {
            //////        lblstatus.Text = "依据就近入学原则请到户口所在地就读。";
            //////    }
            //////    else
            //////    {
            //////        switch (StudentInfo.Current.Status)
            //////        {
            //////            case 0:
            //////                lblstatus.Text = "待分配学校";
            //////                break;
            //////            case 1:
            //////                lblstatus.Text = "已分配到：" + s.Name + ",待学校审核";
            //////                break;
            //////            case 2:
            //////                lblstatus.Text = "初审通过。分配的学校为:" + s.Name + "。";
            //////                if (StudentInfo.Current.Level == 0)
            //////                {
            //////                    lblstatus.Text += s.AInfo;
            //////                }
            //////                if (StudentInfo.Current.Level == 1)
            //////                {
            //////                    lblstatus.Text += s.BInfo;
            //////                }
            //////                if (StudentInfo.Current.Level == 2)
            //////                {
            //////                    lblstatus.Text += s.CInfo;
            //////                }
            //////                if (StudentInfo.Current.Level == 3)
            //////                {
            //////                    lblstatus.Text += s.DInfo;
            //////                }
            //////                btnadd.Enabled = false;
            //////                break;
            //////        }
            //////    }
            //////}
            //////else
            //////{
            //////    lblstatus.Text = "不足龄。";
            //////}
            //txtname.Value = StudentInfo.Current.TrueName;//学生姓名
            //txtIDCardNumber.Value = StudentInfo.Current.IDCardNumber;//学生身份证
            ////性别
            //if (StudentInfo.Current.Sex)
            //{
            //    ddlsex.SelectedValue = "1";
            //}
          //  Birthday.Value = StudentInfo.Current.Birthday.ToString("yyyy-MM-dd");//出生年月
            //////////txtHouseAreaInfo.Value = StudentInfo.Current.Hobby;//兴趣爱好
            //////////txtFirstGuardianName.Value = StudentInfo.Current.FirstGuardianName;//第一监护人姓名
            //////////txtFirstGuardianUnit.Value = StudentInfo.Current.FirstGuardianUnit;//第一监护人工作单位
            //////////txtFirstGuardianPhone.Value = StudentInfo.Current.FirstGuardianPhone;//第一监护人联系电话
            //////////txtFirstRelationship.Value = StudentInfo.Current.FirstRelationship;  //第一监护人和他的关系
            //////////txtSecGuardianName.Value = StudentInfo.Current.SecGuardianName;//第二监护人姓名
            //////////txtSecGuardianUnit.Value = StudentInfo.Current.SecGuardianUnit;//第二监护人工作单位
            //////////txtSecGuardianPhone.Value = StudentInfo.Current.SecGuardianPhone;//第二监护人联系电话
            //////////txtSecRelationship.Value = StudentInfo.Current.SecRelationship;  //第二监护人和他的关系
            //////////hidstuid.Value = StudentInfo.Current.SchID.ToString();       //所属学校
            //////////hidhous.Value = StudentInfo.Current.HouseAreaID.ToString();  //户口所在地(0经济技术开发区1市内其它区2省内市外、外省外市)
            //////////hidsid.Value = StudentInfo.Current.ScommAreaID.ToString();   //住房社区
            //////////hidsname.Value = StudentInfo.Current.ScommName;              //社区名称
            //////////hidxid.Value = StudentInfo.Current.XcommAreaID.ToString();   //住房小区
            //////////hidxname.Value = StudentInfo.Current.XcommName;              //小区名称
            //////////txtHouseNumber.Value = StudentInfo.Current.HouseNumber;      //门牌号
            //////////txtHouseCard.Value = StudentInfo.Current.HouseCard;          //房产号

            //////string sql = "select * from " + ETableName.Students + " where IDCardNumber='" + Cookies.Get("IDCardNumber") + "' and LoginPswd='" + Cookies.Get("LoginPswd") + "'";
            string sql = "select * from " + ETableName.Students + " where IDCardNumber='" + CookiesInfo.GetValue("Robo", "IDCardNumber") + "' and LoginPswd='" + CookiesInfo.GetValue("Robo", "LoginPswd") + "'";
            DataTable dt = DBAction.GetDTFromSQL(sql);
            if (dt.Rows.Count > 0)
            {
                lblname.Text = Convert.ToString(dt.Rows[0]["TrueName"]);//学生名称
                SchoolInfo s = new SchoolInfo();
                s.GetSchoolInfoByID(Convert.ToInt32(dt.Rows[0]["SchID"]));
                //是否足龄
                if (Convert.ToBoolean(dt.Rows[0]["IsMatured"]))
                {
                    //是否是室内区外学生
                    //if (Convert.ToInt32(dt.Rows[0]["SchID"]) == 0 && Convert.ToInt32(dt.Rows[0]["HouseAreaID"])== 1)
                    if(false)
                    {
                        lblstatus.Text = "依据就近入学原则请到户口所在地就读。";
                    }
                    else
                    {
                        switch (Convert.ToInt32(dt.Rows[0]["Status"]))
                        {
                            case 0:
                                lblstatus.Text = "待分配学校";
                                break;
                            case 1:
                                //lblstatus.Text = "已分配到：" + s.Name + ",待学校审核";
                                lblstatus.Text = "待对口服务学校审核";
                                break;
                            case 2:
                                lblstatus.Text = "初审通过。分配的学校为:" + s.Name + "。";
                                if (Convert.ToInt32(dt.Rows[0]["Level"]) == 0)
                                {
                                    lblstatus.Text += s.AInfo;
                                }
                                if (Convert.ToInt32(dt.Rows[0]["Level"]) == 1)
                                {
                                    lblstatus.Text += s.BInfo;
                                }
                                if (Convert.ToInt32(dt.Rows[0]["Level"]) == 2)
                                {
                                    lblstatus.Text += s.CInfo;
                                }
                                btnadd.Enabled = false;
                                break;
                            case 3:
                                lblstatus.Text = "依据就近入学原则请到户口所在地就读。" ;
                                break;
                        }
                    }
                }
                else
                {
                    lblstatus.Text = "不足龄。";
                }
                this.ViewState["StudentID"] = Convert.ToString(dt.Rows[0]["ID"]);//学生ID
                this.ViewState["Adjustment"] = Convert.ToString(dt.Rows[0]["Adjustment"]);//是否接受调剂
                txtname.Value = Convert.ToString(dt.Rows[0]["TrueName"]); //学生姓名
                txtIDCardNumber.Value = Convert.ToString(dt.Rows[0]["IDCardNumber"]);//学生身份证
                //性别
                if (Convert.ToBoolean(dt.Rows[0]["Sex"]))
                {
                    ddlsex.SelectedValue = "1";
                }
                //txtHouseAreaInfo.Value = Convert.ToString(dt.Rows[0]["Hobby"]);//兴趣爱好
                txtFirstGuardianName.Value = Convert.ToString(dt.Rows[0]["FirstGuardianName"]); //第一监护人姓名
                txtFirstGuardianUnit.Value = Convert.ToString(dt.Rows[0]["FirstGuardianUnit"]); //第一监护人工作单位
                txtFirstGuardianPhone.Value = Convert.ToString(dt.Rows[0]["FirstGuardianPhone"]); //第一监护人联系电话
                txtFirstRelationship.Value = Convert.ToString(dt.Rows[0]["FirstRelationship"]);   //第一监护人和他的关系
                txtSecGuardianName.Value = Convert.ToString(dt.Rows[0]["SecGuardianName"]);//第二监护人姓名
                txtSecGuardianUnit.Value = Convert.ToString(dt.Rows[0]["SecGuardianUnit"]); //第二监护人工作单位
                txtSecGuardianPhone.Value = Convert.ToString(dt.Rows[0]["SecGuardianPhone"]); //第二监护人联系电话
                txtSecRelationship.Value = Convert.ToString(dt.Rows[0]["SecRelationship"]); //第二监护人和他的关系
                hidstuid.Value = Convert.ToString(dt.Rows[0]["SchID"]);        //所属学校
                hidhous.Value = Convert.ToString(dt.Rows[0]["HouseAreaID"]);  //户口所在地(0经济技术开发区1市内其它区2省内市外、外省外市)

                pianid.Value = Convert.ToString(dt.Rows[0]["pianid"]);   //住房社区
                ViewState["pianid"] = Convert.ToString(dt.Rows[0]["pianid"]);   //住房社区
                pianname.Value = Convert.ToString(dt.Rows[0]["pianname"]); 

                hidsid.Value = Convert.ToString(dt.Rows[0]["ScommAreaID"]);   //住房社区
                ViewState["hidsid"] = Convert.ToString(dt.Rows[0]["ScommAreaID"]);   //住房社区
                ViewState["hidhous"] = Convert.ToString(dt.Rows[0]["HouseAreaID"]);   //户口所在地(0经济技术开发区1市内其它区2省内市外、外省外市)
                hidsname.Value = Convert.ToString(dt.Rows[0]["ScommName"]);           //社区名称

                txt.Value = Convert.ToString(dt.Rows[0]["Ext1"]); //，门栋号
                radio.Value = Convert.ToString(dt.Rows[0]["IsSelf"]);
                ViewState["radio"] = Convert.ToString(dt.Rows[0]["IsSelf"]); //自有房

                hidxid.Value = Convert.ToString(dt.Rows[0]["XcommAreaID"]);  //住房小区
                hidxname.Value = Convert.ToString(dt.Rows[0]["XcommName"]);              //小区名称
                txtHouseNumber.Value = Convert.ToString(dt.Rows[0]["HouseNumber"]);     //门牌号
                txtHouseCard.Value = Convert.ToString(dt.Rows[0]["HouseCard"]);         //房产号
                this.StudentType.Value= Convert.ToString(dt.Rows[0]["StudentType"]); //学生类型用来判断是否是外籍学生
                ViewState["StudentType"] = Convert.ToString(dt.Rows[0]["StudentType"]); //学生类型用来判断是否是外籍学生
                if (ViewState["StudentType"].ToString() == "wj")
                {
                    this.hiddate.Value = Convert.ToDateTime(dt.Rows[0]["Birthday"]).ToString("yyyy-MM-dd");
                }

                ddlHouseIngoingTime.Value = Convert.ToString(dt.Rows[0]["HouseIngoingTime"]);//户口迁入时间
                HousingOccupancyTime.Value = Convert.ToString(dt.Rows[0]["HousingOccupancyTime"]);//住房入住时间
                txtPermanentAddress.Value = Convert.ToString(dt.Rows[0]["PermanentAddress"]);//户籍地址

                Preschools.Value = Convert.ToString(dt.Rows[0]["PreschoolsID"].ToString());


                ViewState["ServicesDivision"] = Convert.ToString(dt.Rows[0]["ServicesDivision"].ToString());// 是否进行了服务划分（0，没有；1划分了）
            }


            if (Convert.ToInt32(dt.Rows[0]["Status"].ToString().Trim()) == 2)
            {
                int Recrive = Convert.ToInt32(dt.Rows[0]["Level"].ToString().Trim());
                int schId = Convert.ToInt32(dt.Rows[0]["SchId"].ToString().Trim());
                Repeater3.DataSource = DBAction.GetDTFromSQL("select top 6 * from NoticeParents where (Recrive=9 or Recrive=" + Recrive + ") and Status=0 and SchId=" + schId + " order by id desc");
                Repeater3.DataBind();
            }

            if (Convert.ToInt32(dt.Rows[0]["Status"].ToString().Trim()) == 3)//被放弃
            {
                //绑定公告
                Repeater2.DataSource = DBAction.GetDTFromSQL("select top 6 * from Notice where (Recrive=3) and Status=0 order by id desc");
                Repeater2.DataBind();
            }
            else
            {
                //绑定公告
                Repeater2.DataSource = DBAction.GetDTFromSQL("select top 6 * from Notice where (Recrive=0 or Recrive=2) and Status=0 order by id desc");
                Repeater2.DataBind();
            }
            
        }
        //提交
        protected void btnadd_Click(object sender, EventArgs e)
        {
            StudentInfo student_Info = new StudentInfo();
            student_Info.ID = Convert.ToInt32(this.ViewState["StudentID"].ToString().Trim());//学生ID
            student_Info.TrueName = txtname.Value.Trim();//学生姓名
            student_Info.IDCardNumber = txtIDCardNumber.Value.Trim();//学生身份证
            student_Info.Sex = ddlsex.SelectedValue == "0" ? false : true;//性别0男1女
           // student_Info.Hobby = txtHouseAreaInfo.Value;//兴趣爱好
            student_Info.FirstGuardianName = txtFirstGuardianName.Value;//第一监护人姓名
            student_Info.FirstGuardianUnit = txtFirstGuardianUnit.Value;//第一监护人工作单位
            student_Info.FirstGuardianPhone = txtFirstGuardianPhone.Value;//第一监护人联系电话
            student_Info.FirstRelationship = txtFirstRelationship.Value;  //第一监护人和他的关系
            student_Info.SecGuardianName = txtSecGuardianName.Value;//第二监护人姓名
            student_Info.SecGuardianUnit = txtSecGuardianUnit.Value;//第二监护人工作单位
            student_Info.SecGuardianPhone = txtSecGuardianPhone.Value;//第二监护人联系电话
            student_Info.SecRelationship = txtSecRelationship.Value;  //第二监护人和他的关系
            student_Info.SchID = Convert.ToInt32(hidstuid.Value);//所属学校
            student_Info.Status = Convert.ToInt32(hidstuid.Value) == 0 ? 0 : 1;//信息状态(0未分配1已分配2初审通过3初审不通过)
            student_Info.RegisterTime = DateTime.Now;//登记时间
            student_Info.PhoneStatusText = "";//电话回访反馈说明
            student_Info.PhoneStatus = false;//电话回访状态(0未回访1回访)
            student_Info.IsDelete = false;//是否删除(0未删除 1删除)
            student_Info.IsRecord = false;//是否代录
            student_Info.HouseIngoingTime = ddlHouseIngoingTime.Value;//户口迁入时间
            student_Info.HousingOccupancyTime = HousingOccupancyTime.Value;//住房入住时间
            student_Info.PermanentAddress = txtPermanentAddress.Value;//户籍地址
            student_Info.ServicesDivision = Convert.ToInt32(this.ViewState["ServicesDivision"].ToString());// 是否进行了服务划分（0，没有；1划分了）
            if (ViewState["StudentType"].ToString() == "wj")
            {
                student_Info.HouseIngoingTime ="";//户口迁入时间
                student_Info.PermanentAddress ="";//户籍地址
                student_Info.Birthday = DateTime.Parse(this.hiddate.Value);
                student_Info.IsMatured = true;
                student_Info.HouseAreaID = 3;
            }
            else
            {
                //获取身份证上的时间 进行比较 是否足龄
                string stuDate = txtIDCardNumber.Value.Trim().Substring(6, 4) + "-" + txtIDCardNumber.Value.Trim().Substring(10, 2) + "-" + txtIDCardNumber.Value.Trim().Substring(12, 2);
                student_Info.Birthday = Convert.ToDateTime(stuDate); //出生年月
                //足龄条件
                string yea = (DateTime.Now.Year - 6) + "-09-01";
                //身份证时间和足龄条件进行对比
                int isyea = DateTime.Compare(Convert.ToDateTime(yea), Convert.ToDateTime(stuDate));
                student_Info.IsMatured = isyea > 0 ? true : false;//是否足龄
                student_Info.HouseAreaID = Convert.ToInt32(hidhous.Value);   //户口所在地(0经济技术开发区1市内其它区2省内市外、外省外市)
            }
            student_Info.ScommAreaID = Convert.ToInt32(hidsid.Value);   //住房社区
            student_Info.XcommAreaID = Convert.ToInt32(hidxid.Value);   //住房小区
            student_Info.LevelNum = 0;   //住房社区
            student_Info.ScommName = hidsname.Value;//社区名称
            student_Info.XcommName = hidxname.Value;//小区名称
            student_Info.SignUpNum = "42011111";//登记单号
            student_Info.HouseNumber = txtHouseNumber.Value;//门牌号
            StudentInfo.Current.HouseNumber = txtHouseNumber.Value ;//门牌号,如：M-M-M

            student_Info.HouseCard = txtHouseCard.Value;//房产号
            student_Info.Level = -1;//住房社区

            student_Info.IsSelf = Convert.ToInt32(radio.Value);
            student_Info.Ext1 = txt.Value;//单独存储门栋，方便以后的服务划分，按照门栋
            student_Info.Ext2 = "";
            student_Info.Ext3 = "1";//不是代录
            student_Info.Ext4 = "";//0为特殊人才
            student_Info.Ext5 = "";//

            StudentInfo.Current.IsSelf = Convert.ToInt32(radio.Value);//是否为自有房产（0是1不是）
            StudentInfo.Current.Ext1 = txt.Value;//单独存储门栋，方便以后的服务划分，按照门栋
            StudentInfo.Current.Ext2 = "";
            StudentInfo.Current.Ext3 = "1";//不是代录
            StudentInfo.Current.Ext4 = "";//0为特殊人才
            StudentInfo.Current.Ext5 = "";//

            student_Info.pianid = Convert.ToInt32(pianid.Value);   //住房片区
            student_Info.pianname = pianname.Value;//片区名称

            student_Info.PreschoolsID = int.Parse(Preschools.Value);//片区名称

            student_Info.Adjustment =this.ViewState["Adjustment"].ToString().Trim();//是否接受调剂
            switch (student_Info.HouseAreaID)
            {
                case 0:
                    student_Info.Level = 0;//学生等级
                    break;
                case 1:
                    student_Info.Level = 1;//学生等级
                    break;
                case 2:
                    student_Info.Level = 1;//学生等级
                    break;
                case 3:
                    student_Info.Level = 1;//学生等级
                    break;
                default:
                    student_Info.Level = 0;//学生等级
                    break;
            }
            //学生等级
            if ((student_Info.ScommName == "其他" && student_Info.HouseAreaID == 2) || (student_Info.ScommName == "其他" && student_Info.HouseAreaID == 3))
            {
                student_Info.Level = 2;
                if (hidAdjustment.Value.ToString().Trim()=="0")
                {
                    if (this.ViewState["Adjustment"].ToString() != "")
                    {
                        student_Info.Adjustment = this.ViewState["Adjustment"].ToString().Trim();
                    }
                    else
                    {
                        student_Info.Adjustment = "服从";
                    }
                }
                else
                {
                    student_Info.Adjustment =hidAdjustment.Value.ToString().Trim();
                }
            }
            if (student_Info.ScommName == "其他")
            {
                student_Info.ServicesDivision = 1;
            }
            if (student_Info.Level != 2)
            {
                student_Info.Adjustment = "";
            }
            if (student_Info.MdfAccount(student_Info))
            {
                Message.Send(10012);
            }
            else
            {
                Message.Send(10013);
            }
        }
    }
}